﻿using _13.代理模式.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13.代理模式.Services
{
    public class MathProxy : IMath
    {
        private Math math = new Math();
        public double Add(double x, double y)
        {
            var result = math.Add(x, y);
            Console.WriteLine($"{x}+{y}={result}");
            return result;
        }

        public double Divide(double x, double y)
        {
            if (y == 0)
            {
                Console.WriteLine("0不能作为除数");
                return 0;
            }
            var result = math.Divide(x, y);
            Console.WriteLine($"{x}/{y}={result}");
            return result;
        }

        public double Multiply(double x, double y)
        {
            var result = math.Multiply(x, y);
            Console.WriteLine($"{x}*{y}={result}");
            return result;
        }

        public double Subtract(double x, double y)
        {
            var result = math.Subtract(x, y);
            Console.WriteLine($"{x}-{y}={result}");
            return result;
        }
    }
}
